'\" te
.\" Copyright (c) 1982-2007 AT&T Knowledge Ventures
.\" To view license terms, see http://www.opensource.org/licenses/cpl1.0.txt
.\" Portions Copyright (c) 2007, Sun Microsystems, Inc.
.TH BUILTIN 1 "May 1, 2007"
.SH NAME
builtin \- ksh93 built-in function to add, delete, or display shell built-ins
.SH SYNOPSIS
.LP
.nf
\fBbuiltin\fR [\fB-ds\fR] [\fB-f\fR \fIlib\fR] [\fIpathname\fR ...]
.fi

.SH DESCRIPTION
.sp
.LP
The \fBksh93\fR \fBbuiltin\fR command adds, deletes, or displays built-in
commands in the current shell environment. A built-in command executes in the
current shell process and can have side effects in the current shell. On most
systems, the invocation time for built-in commands is one or two orders of
magnitude less than commands that create a separate process.
.sp
.LP
For each \fIpathname\fR specified, the basename of the pathname determines the
name of the built-in. For each basename, the shell looks for a C level function
in the current shell whose name is determined by pre-pending \fBb_\fR to the
built-in name. If \fIpathname\fR contains a forward slash (\fB/\fR), the
built-in is bound to \fIpathname\fR. A built-in bound to a pathname is only
executed if \fIpathname\fR is the first executable found during a path search.
Otherwise, built-ins are found prior to performing the path search.
.sp
.LP
If \fIpathname\fR is not specified, \fBbuiltin\fR displays the current list of
built-ins, or just the special built-ins if the \fB-s\fR option is specified,
on standard output. The full pathname for built-ins that are bound to pathnames
are displayed.
.sp
.LP
Libraries containing built-ins can be specified with the \fB-f\fR option. If
the library contains a function named \fBlib_init()\fR, this function is
invoked with argument \fB0\fR when the library is loaded. The \fBlib_init()\fR
function can load built-ins by invoking an appropriate C level function. In
this case there is no restriction on the C level function name.
.sp
.LP
The C level function is invoked with three arguments. The first two are the
same as \fBmain()\fR and the third one is a pointer.
.sp
.LP
The \fBksh93\fR \fBbuiltin\fR command cannot be invoked from a restricted
shell.
.SH OPTIONS
.sp
.LP
The following options are supported:
.sp
.ne 2
.na
\fB\fB-d\fR\fR
.ad
.RS 10n
Delete each of the specified built-ins. Special built-ins cannot be deleted.
.RE

.sp
.ne 2
.na
\fB\fB-f\fR \fIlib\fR\fR
.ad
.RS 10n
On systems with dynamic linking, load and search for built-ins in the shared
library, \fIlib\fR.
.sp
Libraries are searched for in \fB$PATH\fR and system dependent library
directories. The system dependent shared library prefix or suffix can be
omitted. Once a library is loaded, its symbols become available for the current
and subsequent invocations of \fBbuiltin\fR. Multiple libraries can be
specified with separate invocations of \fBbuiltin\fR. Libraries are searched in
the reverse order in which they are specified.
.RE

.sp
.ne 2
.na
\fB\fB-s\fR\fR
.ad
.RS 10n
Display only the special built-ins.
.RE

.SH OPERANDS
.sp
.LP
The following operands are supported:
.sp
.ne 2
.na
\fB\fIpathname\fR\fR
.ad
.RS 12n
Specifies the \fIpathname\fR. The basename of the pathname determines the name
of the built-in.
.RE

.SH EXIT STATUS
.sp
.LP
The following exit values are returned:
.sp
.ne 2
.na
\fB\fB0\fR\fR
.ad
.RS 6n
Successful completion.
.RE

.sp
.ne 2
.na
\fB\fB>0\fR\fR
.ad
.RS 6n
An error occurred.
.RE

.SH EXAMPLES
.LP
\fBExample 1 \fRLoading a \fBbuiltin\fR Command
.sp
.LP
The following example loads a \fBbuiltin\fR command \fBmycmd\fR from the
library \fBlibfoo.so\fR:

.sp
.in +2
.nf
example% builtin -f foo mycmd
.fi
.in -2
.sp

.SH AUTHORS
.sp
.LP
David Korn, \fBdgk@research.att.com\fR
.SH ATTRIBUTES
.sp
.LP
See \fBattributes\fR(7) for descriptions of the following attributes:
.sp

.sp
.TS
box;
c | c
l | l .
ATTRIBUTE TYPE	ATTRIBUTE VALUE
_
Interface Stability	Uncommitted
.TE

.SH SEE ALSO
.sp
.LP
.BR ksh93 (1),
.BR whence (1),
.BR attributes (7)
